package mementoPattern

/**
 * 发起人角色
 */
class Originator(private var state: String) {

    fun setState(state: String) {
        this.state = state
    }

    fun getState(): String {
        return this.state
    }

    /**
     * 创建备忘录
     */
    fun createMemento(): Memento {
        return Memento(state)
    }

    /**
     * 恢复备忘录
     */
    fun restoreMemento(memento: Memento) {
        this.state = memento.getState()
    }
}